package stream;

import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;

public class MoreParalleSource implements ParallelSourceFunction<Long> {
//    定义bool 类型数据
    private boolean IsRunging = true;
    private long count = 0;


    public void run(SourceContext<Long> sourceContext) throws Exception {
        while (IsRunging){
            sourceContext.collect(count);
            count++;
        //    每秒产生数据
            Thread.sleep(1000);
        }
    }

    public void cancel() {
        IsRunging = false;
    }
}
